package top.longmarch.flow.ai;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;

@Slf4j
@Api(tags = "流程引擎")
@RestController
@RequestMapping("/flow/chat")
public class ChatApi {

    @ApiOperation(value = "查看组件说明")
    @PostMapping
    public ResponseEntity<ResponseBodyEmitter> conversation(@RequestBody String body) {
        return ResponseEntity.ok()
                .contentType(AsyncResponseUtil.TEXT_EVENT_STREAM_UTF8)
                .body(AIUtil.streamChat2(body));
    }

}
